package com.springboot.frame.excel.util;

import org.apache.commons.lang3.ClassUtils;

import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author madman
 */
public final class SupportKit {

  /**
   * 支持类型集
   */
  private static final List<Class<?>> SUPPORTS = new ArrayList<>();

  static {
    SUPPORTS.addAll(Arrays.asList(Date.class, java.sql.Date.class, Time.class, Timestamp.class));
    SUPPORTS.add(String.class);
  }

  private SupportKit() {
  }

  /**
   * 判断是否支持该类型
   *
   * @param clazz 类型
   * @return 是否支持
   */
  public static boolean support(Class<?> clazz) {
    return ClassUtils.isPrimitiveOrWrapper(clazz) || SUPPORTS.contains(clazz) || clazz.isEnum();
  }

}
